/*
 * @Author: your name
 * @Date: 2020-07-28 22:12:12
 * @LastEditTime: 2020-07-28 22:26:12
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \react-hooks-app\src\compontent\contextChild.js
 */

  import React, { useContext,useEffect } from 'react';

  import {CountContext} from '../context'

  function ContextChild(){
    let dataCountContext = useContext(CountContext)
    useEffect(()=>{
      console.log('child useEffect');
    })
    return (
      <div>
          <div>我是子组件，父组件共享的数据{dataCountContext.count}----{dataCountContext.name}</div>
          <button onClick={()=>{dataCountContext.addCount()}} > 我要改变父组件的数据</button>
      </div>

    );
  }

  export default ContextChild;
